<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>新增用户</title>
    <link rel="stylesheet" type="text/css" href="./css/main.css" />
    <link rel="stylesheet" type="text/css" href="https://www.layuicdn.com/layui/css/layui.css" />
    <link rel="stylesheet" type="text/css" href="./css/layuiAdminTheme.css" />
    <style type="text/css">

    </style>
</head>
<body>
<script src="./js/main.js" charset="utf-8"></script>
<!--<script src="https://cdn.jsdelivr.net/npm/jquery" charset="utf-8"></script>-->
<script src="https://www.layuicdn.com/layui/layui.js" charset="utf-8"></script>
<script src="./js/jQuery.main.js"></script>

<form class="layui-form" action="" lay-filter="data">

    <div class="layui-form-item">
        <label class="layui-form-label" style="width: 8em;">部门名称：</label>
        <input id="dept" type="text" name="dept" lay-verify="required" autocomplete="" class="layui-input" style="width: 15em;" placeholder="请输入部门名称">
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label"></label>
        <button type="button" class="layui-btn" lay-submit='' >新增部门</button>
    </div>
</form>

<script type="text/javascript">
    var form = null;


    layui.use(['form',"layer"], function() {
        var form=layui.form;
        var layer = layui.layer;

        form.on('submit', function() {
            var data = form.val('data');
            data.dept =$('#dept').val();
            data.userId=sessionStorage.getItem('userId');
            $.ajax({
                url: url + '/sys-dept/add',
                method: 'POST',
                contentType: 'application/json',
                data: JSON.stringify(data),
                success: function (res) {
                    parent.layer.alert(res.msg);
                    if (res.code == 200) parent.switchNav(0);
                }
            })
            })
        });


</script>
</body>
</html>
